package com.example.administrator.myapplication;

import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;

import com.example.administrator.myapplication.fragment.ContentFragment;
import com.example.administrator.myapplication.fragment.LeftMenuFragment;

public class MainActivity extends AppCompatActivity {
    private static final String FRAGMENT_LEFT_MENU = "fragment_left_menu";
    private static final String FRAGMENT_CONTENT = "fragment_content";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initFragment();
    }

    //舒适化fragment 填充给布局文件
    private void initFragment() {
        FragmentManager fm = getSupportFragmentManager(); //得到支持页的管理器
        android.support.v4.app.FragmentTransaction transaction = fm.beginTransaction(); //开始一个事物
        transaction.replace(R.id.fl_left_menu, new LeftMenuFragment(), FRAGMENT_LEFT_MENU);
        transaction.replace(R.id.fl_content, new ContentFragment(), FRAGMENT_CONTENT);
        transaction.commit();

    }
}